/*
 *  This file is part of JFlickrGroupStats.
 *
 *  JFlickrGroupStats is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  JFlickrGroupStats is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with JFlickrGroupStats.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

package jfgs.gui;

import java.awt.Dimension;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

/**
 *
 * @author michalus
 */
public class PodgladFrame extends javax.swing.JFrame {

    /** Creates new form PodgladFrame */
    public PodgladFrame(String path) {

        initComponents();

        setSize(new Dimension(800, 600));

        try {
            wgrajPlik(path);
        } catch(IOException e) {
            e.printStackTrace();
        }

    }

    private void wgrajPlik(String path) throws IOException {

        File f = new File(path);
        FileReader fr = new FileReader(f);        
        
        info.setText(f.getCanonicalPath());

        podglad.read(fr, f.getCanonicalFile());

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        podglad = new javax.swing.JTextArea();
        info = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("JFlickrGroupStats - Podgląd");

        podglad.setColumns(20);
        podglad.setFont(new java.awt.Font("Monospaced", 0, 12)); // NOI18N
        podglad.setRows(5);
        jScrollPane1.setViewportView(podglad);

        getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);

        info.setText("...");
        getContentPane().add(info, java.awt.BorderLayout.PAGE_END);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel info;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea podglad;
    // End of variables declaration//GEN-END:variables

}
